<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>实验管理系统
    </title>
    <link rel='stylesheet prefetch' href="stylesheets\style1.css">
    <link rel="stylesheet" href="stylesheets\style.css">
</head>

<body screen_capture_injected="true">
    <div id="admin">
        <h1 class="h1">实验管理系统</h1>
        <h2 class="h2">Copyright © 2017 版权归我们所有</h2>
        <div class="hr">
            <hr style=" background-color:black; height:1px" />
        </div>
        <div class="hr1">
            <hr style=" background-color:black; height:1px" />
        </div>
        <div class="wrapper1">
            <h2 style="font-size:18px">管理员:
                <%- user.name %>
            </h2>
            <h2 style="font-size:18px">请录入教师信息</h2>
            <br> 工号：
            <input type="text" id="teaid" class="form-control" name="username" placeholder="请输入教师工号" />
            <br> 姓名：
            <input type="text" id="teaname" class="form-control" name="username" placeholder="请输入教师姓名" />
            <br> 密码：
            <input type="password" id="teapass" class="form-control" name="password" placeholder="请输入教师密码" />
            <br> 系别：
            <select class="form-control" id="sel1">
    <option value="no">---请选择该教师所在系---</option>
    <option value="游戏系">游戏系</option>
    <option value="软件系">软件系</option>
    <option value="中文系">中文系</option>
    <option value="外语系">外语系</option>
    </select>
            <br>
            <button class="btn btn-lg btn-primary btn-block" type="submit" id="log1">录入教师</button>
            <button class="btn btn-lg btn-primary btn-block" type="submit" id="log2">批量导入</button>
            <button class="btn btn-lg btn-primary btn-block" type="submit" id="del1">删除教师</button>
            <button class="btn btn-lg btn-primary btn-block" type="submit" id="out1">登出账户</button>
        </div>

        <div class="row-fluid">
            <h3>教师列表</h3>
            <table class="table table-hover span12" border=1>
                <thead>
                    <tr>
                        <th>工号</th>
                        <th>用户名</th>
                        <th>密码</th>
                        <th>系别</th>
                    </tr>
                </thead>
                <tbody>
                    <% teacherlist.forEach(function(data){ %>
                        <tr>
                            <td>
                                <%= data.no %>
                            </td>
                            <td>
                                <%= data.name %>
                            </td>
                            <td>
                                <%= data.password %>
                            </td>
                            <td>
                                <%= data.department %>
                            </td>
                        </tr>
                        <% }) %>
                </tbody>
            </table>



        </div>


    </div>
    <script type="text/javascript" src="javascripts/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#out1").click(function () {
                location.href = "logout";
            });
            $("#log2").click(function () {
                location.href = "excelup";
            });
            $("#log1").click(function () {
                var teaid = $("#teaid").val();
                var teaname = $("#teaname").val();
                var teapass = $("#teapass").val();
                var sel = $("#sel1").val();
                if (teaid.length < 4 || teaid.length > 4) {
                    alert("教师工号只能是4位")
                } else if (sel == "no") {
                    alert("请选择系别")
                } else if (teaname.length = 0) {
                    alert("请输入教师姓名")
                } else if (teapass.length = 0) {
                    alert("请输入密码")
                }
                else {
                    var data = { "tid": teaid, "tname": teaname, "tpwd": teapass, "sel": sel };
                    $.ajax({
                        url: 'log1',
                        type: 'post',
                        data: data,
                        success: function (data) {
                        }
                    })
                    location.href = "log1";
                    location.href = "admin"
                }
            });
            $("#del1").click(function () {
                var teaid = $("#teaid").val();
                if (teaid.length = 0) {
                    alert("请输入要删除的教师的工号")
                } else {
                    var data = { "tid": teaid }
                    $.ajax({
                        url: 'del1',
                        type: 'post',
                        data: data,
                        success: function (data) {
                        }
                    })
                    location.href = "admin";
                }
            });
        });
    </script>
</body>

</html>